//
//  SJNetworkHelper.h
//  SJDFBackstage
//
//  Created by armada on 2018/1/22.
//  Copyright © 2018年 Leon Guo. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <AFNetworking/AFNetworking.h>
#import "CommonModel.h"
#import "UserModel.h"

typedef void(^FailureBlockType)(NSError *err);

typedef NS_ENUM(NSUInteger, RequestModuleType) {
    
    RequestModuleTypeMagazine, //zazhi = shanghceng
    
    RequestModuleTypeNews,
    
    RequestModuleTypeSchool,
    
    RequestModuleTypeStudyAbroad,
    
    RequestModuleTypeJob,
    
    RequestModuleTypeMore,
    
    RequestModuleTypeSpecialReport
    
};

@interface SJNetworkHelper : NSObject

+ (instancetype)sharedManager;


+ (NSURLSessionDataTask *)postRequestWithAPI:(NSString *)api
                                    Withtype:(NSString *)type
                                   withParam:(NSDictionary *)param
                                 withSuccess:(void(^)(id rsp))success
                                 withFailure:(void(^)(NSString *msg))failure
                                 withUnLogin:(void(^)(void))unlogin;



// 登录接口
- (void)userLoginWithUsername:(NSString *)username
                     password:(NSString *)password
                      success:(void(^)(UserModel *model))successBlock
                      failure:(FailureBlockType)failureBlock;

//注册
- (void)userRegisterWithUsername:(NSString *)username
                            displayname:(NSString *)displayname
                           email:(NSString *)email
                          mobile:(NSString *)mobile
                        password:(NSString *)password
                         success:(void(^)(void))successBlock
                         failure:(FailureBlockType)failureBlock;

// 获取首页数据
- (void)getDataInModule:(RequestModuleType)moduleType
                toalNum:(NSUInteger)toalNum
                success:(void(^)(NSArray<CommonModel *> *model))successBlock
                failure:(FailureBlockType)failureBlock;

//  获取购物车
- (void)getshoppingWithAccessToken:(NSString *)accesstoken
                           success:(void(^)(void))successBlock
                           failure:(FailureBlockType)failureBlock;


//  保存购物车
- (void)saveshoppingWithAccessToken:(NSString *)accesstoken
                           success:(void(^)(void))successBlock
                           failure:(FailureBlockType)failureBlock;

//  添加收货地址
-  (void)addAddressWithAccessToken:(NSString *)accesstoken
                           success:(void(^)(void))successBlock
                           failure:(FailureBlockType)failureBlock;

//  编辑收货地址
-  (void)editAddressWithAccessToken:(NSString *)accesstoken
                           success:(void(^)(void))successBlock
                           failure:(FailureBlockType)failureBlock;

//   新增订单
- (void)neworderWithAccessToken:(NSString *)accesstoken
                           success:(void(^)(void))successBlock
                           failure:(FailureBlockType)failureBlock;

//   获取订单
- (void)getorderWithAccessToken:(NSString *)accesstoken
                        success:(void(^)(void))successBlock
                        failure:(FailureBlockType)failureBlock;

//   获取全部订单
- (void)getallorderWithAccessToken:(NSString *)accesstoken
                        success:(void(^)(void))successBlock
                        failure:(FailureBlockType)failureBlock;


//   删除订单
- (void)removeorderWithAccessToken:(NSString *)accesstoken
                        success:(void(^)(void))successBlock
                        failure:(FailureBlockType)failureBlock;


@end
